package com.moon.annotation.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

public class XMLAspect {
	public void doAfter(JoinPoint jp) {
		System.out.println("Ending Method: "+ jp.getTarget().getClass().getSimpleName() + "."+ jp.getSignature().getName());
	}

	public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
		long time = System.currentTimeMillis();
		Object retVal = pjp.proceed();
		time = System.currentTimeMillis() - time;
		System.out.println("Process Method Time: " + time + " ms");
		return retVal;
	}

	public void doBefore(JoinPoint jp) {
		System.out.println("Begining Method: "+jp.getTarget().getClass().getSimpleName()+"."+jp.getSignature().getName());
	}

	public void doThrowing(JoinPoint jp, Throwable ex) {
		System.out.println("Method: " + jp.getTarget().getClass().getSimpleName()+ "." + jp.getSignature().getName() + " throw exception");
		ex.printStackTrace();
	}
}
